from py2neo import Graph
# Create py2neo connection
graph = Graph(host="localhost",auth=("neo4j","123"))

def Test():
    global graph
    commonSql = ''' create (r:Yc{name:"防风"})create (x1:Xx{name:"农田管理"})
                    create (x2:Xx{name:"种植管理"})
                    create (x3:Xx{name:"采收管理"})
                    create (x4:Xx{name:"加工管理"})
                    create (x5:Xx{name:"物流管理"})
                    
                    create (x1)-[:Re{name:"溯源"}]->(r)
                    create (x2)-[:Re{name:"溯源"}]->(r)
                    create (x3)-[:Re{name:"溯源"}]->(r)
                    create (x4)-[:Re{name:"溯源"}]->(r)
                    create (x5)-[:Re{name:"溯源"}]->(r)
                    
                    create (c1:Cat{name:"区块"})
                    create (c2:Cat{name:"地块"})
                    create (c3:Cat{name:"农田环境"})
                    create (c4:Cat{name:"基地环境"})
                    create (c5:Cat{name:"加工信息"})
                    create (c6:Cat{name:"包装信息"})
                    create (c7:Cat{name:"采收信息"})
                    create (c8:Cat{name:"产品信息"})
                    create (c9:Cat{name:"物流信息"})
                    create (c1)-[:Re{name:"RE"}]->(x1)
                    create (c2)-[:Re{name:"RE"}]->(x1)
                    create (c3)-[:Re{name:"RE"}]->(x2)
                    create (c4)-[:Re{name:"RE"}]->(x2)
                    create (c5)-[:Re{name:"RE"}]->(x4)
                    create (c6)-[:Re{name:"RE"}]->(x4)
                    create (c7)-[:Re{name:"RE"}]->(x3)
                    create (c8)-[:Re{name:"RE"}]->(x3)
                    create (c9)-[:Re{name:"RE"}]->(x5)
                    
                    create (z1:Zb{name:"土壤类型"})
                    create (z2:Zb{name:"区域编号"})
                    create (z3:Zb{name:"负责人"})
                    create (z4:Zb{name:"面积"})
                    create (z1)-[:Re{name:"RE"}]->(c1)
                    create (z2)-[:Re{name:"RE"}]->(c1)
                    create (z3)-[:Re{name:"RE"}]->(c1)
                    create (z4)-[:Re{name:"RE"}]->(c1)
                    
                    create (z5:Zb{name:"周长"})
                    create (z6:Zb{name:"农户名"})
                    create (z7:Zb{name:"农户性别"})
                    create (z8:Zb{name:"身份证号"})
                    create (z9:Zb{name:"地块编号"})
                    create (z10:Zb{name:"面积"})
                    create (z5)-[:Re{name:"RE"}]->(c2)
                    create (z6)-[:Re{name:"RE"}]->(c2)
                    create (z7)-[:Re{name:"RE"}]->(c2)
                    create (z8)-[:Re{name:"RE"}]->(c2)
                    create (z9)-[:Re{name:"RE"}]->(c2)
                    create (z10)-[:Re{name:"RE"}]->(c2)
                    
                    create (z11:Zb{name:"水文条件"})
                    create (z12:Zb{name:"温湿度"})
                    create (z13:Zb{name:"面积"})
                    create (z14:Zb{name:"作物类型"})
                    create (z15:Zb{name:"地理位置"})
                    create (z11)-[:Re{name:"RE"}]->(c3)
                    create (z12)-[:Re{name:"RE"}]->(c3)
                    create (z13)-[:Re{name:"RE"}]->(c3)
                    create (z14)-[:Re{name:"RE"}]->(c3)
                    create (z15)-[:Re{name:"RE"}]->(c3)
                    
                    create (z16:Zb{name:"气候条件"})
                    create (z17:Zb{name:"负责人"})
                    create (z18:Zb{name:"主要作物"})
                    create (z19:Zb{name:"所属区域"})
                    create (z20:Zb{name:"地理位置"})
                    create (z16)-[:Re{name:"RE"}]->(c4)
                    create (z17)-[:Re{name:"RE"}]->(c4)
                    create (z18)-[:Re{name:"RE"}]->(c4)
                    create (z19)-[:Re{name:"RE"}]->(c4)
                    create (z20)-[:Re{name:"RE"}]->(c4)
                    
                    create (z21:Zb{name:"加工企业"})
                    create (z22:Zb{name:"加工地点"})
                    create (z23:Zb{name:"加工时间"})
                    create (z24:Zb{name:"加工数量"})
                    create (z25:Zb{name:"加工人员"})
                    create (z26:Zb{name:"药材名称"})
                    create (z21)-[:Re{name:"RE"}]->(c5)
                    create (z22)-[:Re{name:"RE"}]->(c5)
                    create (z23)-[:Re{name:"RE"}]->(c5)
                    create (z24)-[:Re{name:"RE"}]->(c5)
                    create (z25)-[:Re{name:"RE"}]->(c5)
                    create (z26)-[:Re{name:"RE"}]->(c5)
                    
                    create (z27:Zb{name:"作物编号"})
                    create (z28:Zb{name:"物流方式"})
                    create (z29:Zb{name:"包装手段"})
                    create (z30:Zb{name:"包装地点"})
                    create (z31:Zb{name:"包装时间"})
                    create (z32:Zb{name:"包装企业"})
                    create (z33:Zb{name:"包装设备"})
                    create (z27)-[:Re{name:"RE"}]->(c6)
                    create (z28)-[:Re{name:"RE"}]->(c6)
                    create (z29)-[:Re{name:"RE"}]->(c6)
                    create (z30)-[:Re{name:"RE"}]->(c6)
                    create (z31)-[:Re{name:"RE"}]->(c6)
                    create (z32)-[:Re{name:"RE"}]->(c6)
                    create (z33)-[:Re{name:"RE"}]->(c6)
                    
                    create (z34:Zb{name:"采收地域"})
                    create (z35:Zb{name:"收集量"})
                    create (z36:Zb{name:"采收作物"})
                    create (z37:Zb{name:"采收人"})
                    create (z38:Zb{name:"采收情况"})
                    create (z34)-[:Re{name:"RE"}]->(c7)
                    create (z35)-[:Re{name:"RE"}]->(c7)
                    create (z36)-[:Re{name:"RE"}]->(c7)
                    create (z37)-[:Re{name:"RE"}]->(c7)
                    create (z38)-[:Re{name:"RE"}]->(c7)
                    
                    create (z39:Zb{name:"产品编号"})
                    create (z40:Zb{name:"作物编号"})
                    create (z41:Zb{name:"作物关联"})
                    create (z42:Zb{name:"作物名称"})
                    create (z39)-[:Re{name:"RE"}]->(c8)
                    create (z40)-[:Re{name:"RE"}]->(c8)
                    create (z41)-[:Re{name:"RE"}]->(c8)
                    create (z42)-[:Re{name:"RE"}]->(c8)
                    
                    create (z43:Zb{name:"物流编号"})
                    create (z44:Zb{name:"物流车辆编号"})
                    create (z45:Zb{name:"物流订单号"})
                    create (z46:Zb{name:"起始地"})
                    create (z47:Zb{name:"目的地"})
                    create (z43)-[:Re{name:"RE"}]->(c9)
                    create (z44)-[:Re{name:"RE"}]->(c9)
                    create (z45)-[:Re{name:"RE"}]->(c9)
                    create (z46)-[:Re{name:"RE"}]->(c9)
                    create (z47)-[:Re{name:"RE"}]->(c9)'''

    graph.run(commonSql)

    print("over.")


if __name__ == "__main__":
    Test()